home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Prog / B-C / C++ FAQ Reference 1.0 / C++ FAQ Reference 1.0.rsrc / TEXT_1032.txt < prev    next >
Encoding:
Text File  |  1993-06-30  |  573 b   |  7 lines

  1. The short answer: yes -- you don't even need the 'cast'.
  2.  
  3. Long answer: a derived class is a specialized version of the base class ('Derived is-a-kind-of-a Base').  The upward conversion is perfectly safe, and happens all the time (a ptr to a Derived is in fact pointing to a [specialized version of a] Base):
  4.     void f(Base* base_ptr);
  5.     void g(Derived* derived_ptr) { f(derived_ptr); }  //perfectly safe; no cast
  6.  
  7. (note that the answer to this question assumes we're talking about 'public' derivation; see below on 'private/protected' inheritance for 'the other kind').